<?php
/**
 * 导航服务层
 * @author maniac
 */
namespace app\common\service;

use app\common\model\Navs AS NavsModel;

class Navs extends Base
{
    /**
     * 获取导航信息
     * @param array  $category_id 导航分类 id
     * @param int    $limit       查询的数量
     * @param string $order       排序条件
     */
    public function navs($category_id, $limit = '', $order = 'list_order DESC,id ASC')
    {
        if (is_numeric($category_id)) {
            $where = [
                ['category_id', 'eq', $category_id],
            ];
        } else {
            $where = [
                ['category_id', 'in', $category_id],
            ];
        }
        $where[] = [
            ['status', 'eq', 0],
        ];
        return NavsModel::field('name,image_id,url')->append(['image_uri'])->where($where)->order($order)->limit($limit)->select()->toArray();
    }
}
